package com.example.bomc.dao;


import com.example.bomc.model.FixStaff;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ManageDAO {
    String TABLE_NAME1 = "user";
    String TABLE_NAME2 = "fixStaff";
    String INSET_FIELDS = " fixnum, fixname, fixwork ,password";
    String SELECT_FIELDS = "choose, trouble, user, time ,reply,assess,fixname";

    /*
     * 审批用户注册
     * */
    @Update({"update",TABLE_NAME1,"set isExamined =1 where name=#{name} "})
    void updateExamined(@Param("name") String  name);

    /*
     * 新增维护人员
     * */
    @Insert({"insert into ", TABLE_NAME2, "(", INSET_FIELDS,") values (#{fixnum},#{fixname},#{fixwork},#{password})"})
    void addFixStaff(FixStaff staff);

    /*
     * 删除维护人员
     * */
    @Delete({"delete from",TABLE_NAME2,"where fixname=#{fixname}"})
    void deleteStaff(@Param("fixname") String fixname);

    /*
     * 问题工单分配给维护人员
     * */
    @Update({"update",TABLE_NAME1,"set fixname =#{fixname} where name=#{name} and trouble=#{trouble} "})
    void fenpeiFix(@Param("name") String  name,@Param("fixname") String  fixname,@Param("trouble") String  trouble);

    /*
     * 查看用户反馈
     * */
    @Select({"select ", SELECT_FIELDS, " from ", TABLE_NAME1})
    List<FixStaff> selSameQuery();


    /*
     * 查看维护人员反馈
     * */
    @Select({"select ", SELECT_FIELDS, " from ", TABLE_NAME2, " where fixname=#{name}"})
    FixStaff selectByFixName(String name);

}
